urlopen error [errno 111] connection refused

Posted by Ui-Gyun Jeong on Stack Overflow See other posts from Stack Overflow or by Ui-Gyun Jeong
Published on 2013-11-10T08:46:38Z Indexed on 2013/11/10 9:53 UTC
Read the original article Hit count: 251

Filed under:
|
|
|

I am doing python exercise with a book 'headfirst python' and making android app by using python and sl4a my code is

import android
import json
import time

from urllib import urlencode
from urllib2 import urlopen

hello_msg     = "Welcome to Coach Kelly's Timing App"
list_title    = 'Here is your list of athletes:'
quit_msg      = "Quitting Coach Kelly's App."
web_server    = 'http://127.0.0.1:8080'
get_names_cgi = '/cgi-bin/generate_name.py'

def send_to_server(url, post_data=None):
    if post_data:
        page = urlopen(url, urlencode(post_data))
    else:
        page = urlopen(url)
    return(page.read().decode("utf8"))

app = android.Android()

def status_update(msg, how_long=2):
    app.makeToast(msg)
    time.sleep(how_long)

status_update(hello_msg)

athlete_names = sorted(json.loads(send_to_server(web_server + get_names_cgi)))
app.dialogCreateAlert(list_title)
app.dialogSetSingleChoiceItems(athlete_names)
app.dialogSetPositiveButtonText('Select')
app.dialogSetNegativeButtonText('Quit')
app.dialogShow()
resp = app.dialogGetResponse().result

status_update(quit_msg) 

this is my code and the result is enter image description here

what is the problem??? I can not figure out what the problem is...

© Stack Overflow or respective owner

Related posts about android

Related posts about python